package com.example.cinema.bindingdata;

import android.view.View;
import android.widget.ImageView;

import androidx.databinding.BindingAdapter;
import androidx.databinding.ObservableField;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.example.cinema.R;
import com.example.cinema.drawview.CollapseText;

//小视屏评论
public class CommentShortData {

    //头像
    @BindingAdapter("comshorturl")
    public static void setimgurl(View view,String url)
    {
        if(url==null)
        {
            return;
        }
        RequestOptions options = new RequestOptions()
                .placeholder(R.mipmap.defaut_img)
                .error(R.mipmap.defaut_img)
                .fallback(R.mipmap.defaut_img);
        Glide.with(view).load(url)
                .apply(options)
                .into((ImageView) view);
    }
    //内容
    @BindingAdapter("comtexts")
    public static void settexts(View view,String text)
    {
        CollapseText collapseText = (CollapseText) view;
        collapseText.setTextcontext(text);
    }

    public ObservableField<String> userimg = new ObservableField<>();//用户头像
    public ObservableField<String> username= new ObservableField<>();//用户名称
    public ObservableField<String> comments= new ObservableField<>();//评论内容
    public ObservableField<String> zannumbe= new ObservableField<>();//点赞数
    public ObservableField<String> usersid = new ObservableField<>();//用户ID


}
